/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2023-12-07 09:26:03
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-04-30 09:58:13
 * @FilePath: /yt-devops/lib/pages/common/select_page/select_page_model.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:yt_devops/components/paging/model/paging_params.dart';
import 'package:yt_devops/components/paging/page_state.dart';

class SelectPageModel<M> extends PagingState<M> {
  @override
  int numberOnePage = 20;
}

/// 配置选择页
/// 注意：目前只写了单选页
///
enum PickType {
  page,
  picker,
}

class SelectPageProp<T> {
  /// 选择类型：picker 底部弹出窗、page 页面
  PickType pickType;

  /// 选择列表
  List<T> list;

  /// 数据名称
  String dataName;

  /// 是否需要搜索功能
  bool isSearch;

  /// 请求时，搜索对应的key
  String? searchKey;

  /// 是否单选;
  bool isSingle;

  /// 初始选中的值;
  List<T> initSelectValues;

  String Function(T) getNameKey;

  dynamic Function(T) getIdByKey;

  /// 请求方法
  Future Function(PagingParams params)? service;

  SelectPageProp(this.dataName,
      {required this.getIdByKey,
      required this.getNameKey,
      this.pickType = PickType.page,
      this.list = const [],
      this.isSearch = true,
      this.searchKey,
      this.isSingle = true,
      this.initSelectValues = const [],
      this.service});
}
